<?php
	require_once('header.php');	
?>
<html>
	<body>
		<head>
			<script type="text/javascript" src="./js/util.js"></script>
			<script type="text/javascript">
				function check_id()
				{
					window.open("check_id.php?id="+document.member_form.id.value,"IDcheck","left=200, top=200, width=250, height=100, scrollbar=no, resizable=yes");
				}
				
				function check_input()
				{
					if(!document.member_form.id.value)
					{
						alert("아이디를 입력하세요");
						document.member_form.id.focus();
						return;
					}
					if(!document.member_form.name.value)
					{
						alert("이름을 입력하세요");
						document.member_form.name.focus();
						return;
					}
					if(!document.member_form.passwd.value)
					{
						alert("비밀번호를 입력하세요");
						document.member_form.passwd.focus();
						return;
					}
					if(!document.member_form.passwd_confirm.value)
					{
						alert("비밀번호확인을 입력하세요");
						document.member_form.passwd.focus();
						return;
					}
					
					if(!document.member_form.email.value)
					{
						alert("이메일 주소를 입력하세요");
						document.member_form.passwd.focus();
						return;
					}
					
					if(!document.member_form.edulevel.value)
					{
						alert("학력을 선택해주세요");
						document.member_form.edulevel.focus();
						return;
					}
					
					if(!document.member_form.age.value)
					{
						alert("연령을 입력해주세요");
						document.member_form.age.focus();
						return;
					}	
					if(!document.member_form.addr.value)
					{
						alert("주소를 입력해주세요");
						document.member_form.addr.focus();
						return;
					}
					if(!document.member_form.phone1.value ||!document.member_form.phone2.value||!document.member_form.phone3.value )
					{
						alert("전화번호를 입력해주세요");
						document.member_form.phone1.focus();
						return;
					}	
					if(!document.member_form.birth1.value ||!document.member_form.birth2.value||!document.member_form.birth3.value )
					{
						alert("생년월일을 입력해주세요");
						document.member_form.birth1.focus();
						return;
					}	
/* 왠지 모르겠지만 동작 안함
					if(!document.member_form.category.value)
					{
						alert("카테고리를 선택해주세요");
						document.member_form.category.focus();
						return;
					}					
	*/				
					if(!document.member_form.keyword.value)
					{
						alert("키워드를 입력해주세요");
						document.member_form.keyword.focus();
						return;
					}					
					
					if(document.member_form.passwd.value != document.member_form.passwd_confirm.value)
					{
						alert("비밀번호가 일치하지 않습니다\n 다시 입력해주세요");
						document.member_form.passwd.focus();
						document.member_form.passwd.select();
						return;
					}
					
					document.member_form.submit();
				}
				
				function reset_form()
				{
					<!-- 주석예압 초기화할 변수들 여기에 집어 넣긔 -->
					document.member_form.id.value = "";
					document.member_form.name.value = "";
					document.member_form.passwd.value = "";
					document.member_form.passwd_confirm.value = "";
					document.member_form.address.value = "";
				}
				function back()
				{
					top.location.href='../login.html';
				}
				</script>
				<link href="./css/form.css" type="text/css" rel="stylesheet" />				
				</head>
				<body topmargin="0">
		
          <form id=member_form name=member_form method=post action=insert_member.php>
          <h1>~ 회원 가입 신청서 양식 ~ </h1>
		  <fieldset>
		    <legend> 필수입력사항 </legend>
			<div>
				<label class="label"> * 아이디 : </label>
                <input type=text size=20 class=m_box maxlength=20 name=id>
                <input type=button value="중복확인" onclick="check_id()">                
            </div>  
            <div>  
             <label class="label"> * 이름 : </label>
             <input type=text size=12 class=m_box maxlength=12 name=name>
			</div>
			
			 <div>
				<label class="label"> * 비밀번호 : </label>
                <input type=password size=10 class=m_box maxlength=12 name=passwd>
             </div> 
             
			 <div>
               <label class="label"> * 비밀번호확인 : </label>
               <input type=password size=10 class=m_box maxlength=12 name=passwd_confirm>
            </div>
			<div>  
			  <label class="label"> * 이메일주소 : </label>
              <input type=text size=20 class=m_box maxlength=20 name=email>                
            </div>   
			<div>  
			  <label class="label"> * 성별 : </label>
              <input type=radio name=gender value=1 checked>남
			  <input type=radio name=gender value=2> 여</td>
            </div>
			<div>
              <label class="label"> * 학력 : </label>              
              <select class=input2 name=edulevel>
				<option value=''>선택</option>
				<option value='1'>중졸 이하</option>
				<option value='2'>고졸</option>
				<option value='3'>초대졸</option>
				<option value='4'>대졸</option>	
				<option value='5'>대학원졸 이상</option>				
				</select>
            </div>
			<div>
				<label class="label"> * 연령 :</label>
                <input type=text size=3 class=m_box maxlength=3 name=age>   
            </div>
			  
			 <div>  
			 <label class="label"> * 주소 : </label>
                 <input type=text size=50 class=m_box maxlength=50 name=addr> 
				<input type=button value="선택" onclick=openPopup("select_location.php?form_name=member_form&addr_field_name=addr","select",320,240)>
             </div>
			<div>
			 <label class="label"> * 전화번호 :</label>              
               <select class=input2 name=phone1 >
				<option value=''>  </option>
				<option value='010'> 010 </option>
				<option value='011'> 011 </option>
				<option value='016'> 016 </option>
				<option value='017'> 017 </option>
				<option value='018'> 018 </option>
				<option value='019'> 019 </option>
			  </select>-
			  <input type=text size=4 class=m_box name=phone2 maxlength=4>-
			  <input type=text size=4 class=m_box name=phone3 maxlength=4>
			</div>
			<div><label class="label"> * 생년월일 :</label>
			    
              <input type=text size=4 class=m_box maxlength=4 name=birth1> 년
			  <input type=text size=2 class=m_box maxlength=2 name=birth2> 월
			  <input type=text size=2 class=m_box maxlength=2 name=birth3> 일   
             </div>
			  
			  
			  
			  
			<div>
			<label class="label"> * 관심 분야 : </label>                
               <?php
			  		require_once('db_connect.php');
					
					$sql = "select * from category";
					
					$result=mysqli_query($conn,$sql);
					$num_row = mysqli_num_rows($result);
					
					$i=1;										
					while($row=mysqli_fetch_array($result))
					{
										
					echo "<input type=checkbox name=category$i value='$row[name]'>";
					echo $row[name];
					$i++;
					
					//if($i==5)
						//echo "<br><br>";
					
					//echo "키워드 : $row[basic_keyword]";				
					}						
			  ?>	    
			</div>		  
            <div>   
			  <label class="label"> * 관심 키워드 : </label>
              <input type=text size=50 class=m_box maxlength=30 name=keyword>                
              
            </div>
		
			<div class="submit" align=center>
		
              <input type=button value="확인" onclick=check_input()>
              <input type=button value="취소" onclick=back()>
			</div>                       
			</fieldset>
            </form>			
			<?
			require_once('footer.php');
			?>
				
				
				
					
					

					